<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div id="app">
        <span>{{age}}</span>
        <span>{{color}}</span>
        <button v-on:click="addAge">点击年龄+1</button>
         <!-- 简写 -->
         <button @click="subtractAge">点击年龄-1</button>
         <button @click="changeColor">点击颜色</button>
    </div>
</body>
</html>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            color:'red',
            age:18
        },
        methods:{
            // 年龄加一
            addAge:function(){
                this.age+=1
            },
            // 年龄减一
            subtractAge(){
                this.age-=1
            },
            // 颜色变换
            changeColor:function(){
                this.color = 'blue'
            }
        }
    })
</script>